<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Profiling</title>


<script type="text/javascript" src="../Profiler.js"></script>
<script type="text/javascript" src="joose-2.1.js"></script>

<script type="text/javascript">


SimpleRequest = function(){
	if (window.XMLHttpRequest) {
	    this._req = new XMLHttpRequest();
	} else {
	    this._req = new ActiveXObject("Microsoft.XMLHTTP");
	}
};

SimpleRequest.prototype.getText = function (urlOrOptions, async, callback, scope) {
    var req = this._req;
    
    var headers;
    var url;
    
    if (typeof urlOrOptions != 'string') {
        headers = urlOrOptions.headers;
        url = urlOrOptions.url;
        async = async || urlOrOptions.async;
        callback = callback || urlOrOptions.callback;
        scope = scope || urlOrOptions.scope;
    } else url = urlOrOptions;
    
    req.open('GET', url, async || false);
    
    if (headers) Joose.O.eachSafe(headers, function (value, name) {
        req.setRequestHeader(name, value);
    });
    
    try {
        req.onreadystatechange = function (event) {  
            if (async && req.readyState == 4) {  
                if (req.status == 200 || req.status == 0) callback.call(scope || this, true, req.responseText);  
                else callback.call(scope || this, false, "File not found: " + url);  
            }  
        };  
        req.send(null);
    } catch (e) {
        throw "File not found: " + url;
    };
    
    if (!async) {
        if (req.status == 200 || req.status == 0) return req.responseText; else throw "File not found: " + url;
    } 
    
    return null;
};

var stressedWithDeps = new SimpleRequest().getText('withDependencies.js');

new Profiler(function () {
    StressTest = undefined;
    __global__.meta.namespaceElements = {};
    eval(stressedWithDeps);
}, "Stressed test with dependencies").run(5).report();

var stressedWODeps = new SimpleRequest().getText('withoutDependencies.js');

new Profiler(function () {    
    eval(stressedWODeps);
}, "Stressed test w/o dependencies").run(5).report();

</script>

</head>

<body>



</body>
</html>